package com.quarantine.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.quarantine.dao.*;
import com.quarantine.model.*;
@Component
@Transactional
public class AnnouncementManager {

	private announcementDao  announcementDao;
	
	@Autowired
	public void setAnnouncementDao(announcementDao announcementDao) {
		this.announcementDao = announcementDao;
	}

	
	
	/***
	 * 保存
	 */
	
	public void save(announcement entity) {
		   announcementDao.save(entity);
		
	}
	    /**
	     * 根据id查找
	     */
	    @Transactional  
		public announcement getById(String id) {
			return announcementDao.findUniqueBy("id", id);
		}
	    
	    /***
	     * 显示后台公告列表
	     * @param page
	     * @return
	     */
	    @Transactional 
	    public Page<announcement> getList(final Page<announcement>page ) {
		return announcementDao.findPage(page, "from announcement order by edit_time desc");
	}
	    /***
	     * 显示前端公告列表
	     * @param page
	     * @return
	     */
	    @Transactional 
	    public Page<announcement> getList2(final Page<announcement>page ) {
		return announcementDao.findPage(page, "from announcement order by input_time desc");
	}
	    @Transactional      
	    /**
	     * 根据id来删除
	     */
	    public void delete(String id){
	    	announcementDao.delete(id);
	    }
	
}
